var fs = require('fs');

var readStream = fs.createReadStream('stream_copy_logo.js');
var n =0;

readStream
    .on('data', function (chunk) {
        n++;
        console.log('data emits');
        console.log(Buffer.isBuffer(chunk));
        console.log(chunk.toString('utf8'));
        readStream.pause();
        console.log('data paused');
        setTimeout(function () {
            console.log('data pause end');
            readStream.resume();
        }, 3000)
    })
    .on('readable', function () {
        console.log('data readable');
    })
    .on('end', function () {
        console.log(n);
        console.log('data ends');
    })
    .on('close', function () {
        console.log('data close');
    })
    .on('error', function (e) {
        console.log('data error' + e.toString());
    })

// 每次传递指定字节数的流，总字节数/传递次数/1024 为每次传递的字节数
